package com.yifeng.repo.base.service.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2024/2/3.
 */
@Getter
@AllArgsConstructor
public enum BaseServiceTypeEnum {
    LBS("lbs", "位置服务"),
    MSG_SEND("msgSend", "消息发送"),
    EVENT_NOTIFY("eventNotify", "事件通知"),
    STORE_LOCATION("storeLocation", "门店位置"),
    VOICE("voice", "语音服务"),
    MQTT("mqtt", "MQTT消息"),
    MCS_MQTT("mcs_mqtt", "消息中心-MQTT消息"),
    ;

    @EnumValue
    @JsonValue
    private final String code;

    private final String name;

    private static final Map<String, BaseServiceTypeEnum> mappings = new HashMap<>(6);

    static {
        for (BaseServiceTypeEnum value : values()) {
            mappings.put(value.getCode(), value);
        }
    }

    public static BaseServiceTypeEnum resolve(String code) {
        return (code != null ? mappings.get(code) : null);
    }

}
